package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

public class CommonwealConstant {

    /**
     * 分润配置类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ShareBenefitConfigType implements IntegerEnum<Integer> {
        /**
         * 0：绿马公益联盟合伙人准入政策及服务积分收益明细
         * 1：服务体系成员邀请会员成为创客，可以获取的服务积分
         * 2：创客直推的爱心小屋下的直推会员产生的订单金额多少分给创客
         */
        PARTNER_CONFIG(0, "绿马公益联盟合伙人准入政策及服务积分收益明细"),
        INVITE_CONFIG(1, "服务体系成员邀请会员成为创客，可以获取的服务积分"),
        ORDERS_CONFIG(2, "创客直推的爱心小屋下的直推会员产生的订单金额多少分给创客"),
        ;
        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ShareBenefitConfigType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static CommonwealConstant.ShareBenefitConfigType getByCode(int code) {
            for (CommonwealConstant.ShareBenefitConfigType value : CommonwealConstant.ShareBenefitConfigType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

}
